import request from '@/utils/request';

export async function queryRole(params) {
  return request('/api/system/role/getByPage', {
    params,
  });
}
export async function removeRole(params) {
  return request(`/api/system/role/delRole?ids=${params.roleId}`, {
    method: 'DELETE',
  });
}
export async function addRole(params) {
  return request('/api/system/role', {
    method: 'POST',
    data: { ...params },
  });
}
export async function updateRole(params) {
  return request('/api/system/role', {
    method: 'PUT',
    data: { ...params },
  });
}

export async function queryRoleMenus(params) {
  return request(`/api/system/sysMenu/getByRole/${params.roleId}`, {
    method: 'GET',
  });
}

export async function queryDepartment(params) {
  return request('/api/department', {
    params,
  });
}
export async function removeDepartment(params) {
  return request(`/api/department?idList=${params.idList}`, {
    method: 'DELETE',
    data: { ...params},
  });
}
export async function addDepartment(params) {
  return request('/api/department', {
    method: 'POST',
    data: { ...params },
  });
}
export async function updateDepartment(params) {
  return request('/api/department', {
    method: 'PUT',
    data: { ...params },
  });
}


export async function queryStaff(params) {
  return request('/api/system/hrmStaffs/getByPage', {
    params,
  });
}
export async function removeStaff(params) {
  return request(`/api/system/hrmStaffs/${params.staffId}`, {
    method: 'DELETE',
    data: { ...params},
  });
}
export async function addStaff(params) {
  return request('/api/system/hrmStaffs', {
    method: 'POST',
    data: { ...params },
  });
}
export async function updateStaff(params) {
  return request('/api/system/hrmStaffs', {
    method: 'PUT',
    data: { ...params },
  });
}


export async function queryAccount(params) {
  return request('/api/user', {
    params,
  });
}
export async function queryEqp(params) {
  return request('/api/equipment', {
    params,
  });
}

export async function queryMaintenance(params) {
  return request('/api/maintence', {
    params,
  });
}

export async function queryMaintenanceHistory(params) {
  return request('/api/maintenceHistory', {
    params,
  });
}

export async function removeMaintenance(params) {
  return request(`/api/maintence?id=${params.id}`, {
    method: 'DELETE',
    data: { ...params},
  });
}

export async function queryMaintenceListByMonth(params) {
  return request(`/api/maintence/queryMaintenceListByMonth`, {
    params,
  });
}

export async function queryMaintenceListByYear(params) {
  return request(`/api/maintence/queryMaintenceListByYear`, {
    params,
  });
}


export async function addMaintenance(params) {
  return request('/api/maintence', {
    method: 'POST',
    data: { ...params },
  });
}
export async function updateMaintenance(params) {
  return request('/api/maintence', {
    method: 'PUT',
    data: { ...params },
  });
}

export async function startMaintenance(params) {
  return request('/api/maintence/start', {
    method: 'POST',
    data: { ...params },
  });
}


export async function removeAccount(params) {
  return request(`/api/user?idList=${params.idList}`, {
    method: 'DELETE',
    data: { ...params},
  });
}

export async function removeEqp(params) {
  return request(`/api/equipment?idList=${params.idList}`, {
    method: 'DELETE',
    data: { ...params},
  });
}

export async function addAccount(params) {
  return request('/api/user', {
    method: 'POST',
    data: { ...params },
  });
}

export async function addEqp(params) {
  return request('/api/equipment', {
    method: 'POST',
    data: { ...params },
  });
}

export async function updateAccount(params) {
  return request('/api/user', {
    method: 'PUT',
    data: { ...params },
  });
}

export async function updateEqp(params) {
  return request('/api/equipment', {
    method: 'PUT',
    data: { ...params },
  });
}

export async function resetPassword(params) {
  return request('/api/user/resetPassword', {
    method: 'PUT',
    data: { ...params },
  });
}

export async function updateAccountStatus(params) {
  return request('/api/system/sysUser/updateStatus', {
    method: 'PUT',
    data: { ...params },
  });
}

// 获取当前登录用户信息
export async function queryLoginAccountInfo(params) {
  return request('/api/getAuthInfo', {
    method: 'GET',
  });
}

// 获取全部菜单信息
export async function queryAllMenu() {
  return request('/api/system/sysMenu/getAllMenuList', {
    method: 'GET',
  });
}
